﻿using Kw.Combinatorics;
using System;

namespace Kw.CombinatoricsExamples
{
    class MulticombinationExample05
    {
        static void Main ()
        {
            int n = 9;
            int k = 7;
            long rank = 5973;

            Multicombination mc = new Multicombination (n, k, rank);

            // Elements may be accessed using the default iterator:

            foreach (int element in mc)
                Console.Write ((char) ('A' + element));

            Console.WriteLine ("\n");

            // Elements may be accessed using the index operator:

            for (int i = 0; i < mc.Picks; ++i)
                Console.WriteLine ("Element at {0} is {1}", i, mc[i]);
        }

        /* Output:

        DEFFFHI

        Element at 0 is 3
        Element at 1 is 4
        Element at 2 is 5
        Element at 3 is 5
        Element at 4 is 5
        Element at 5 is 7
        Element at 6 is 8

        */
    }
}
